package com.nineclock.message.listener;

import com.nineclock.message.pojo.NcMessage;
import com.nineclock.message.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "messagePushTopic",  consumerGroup = "messagePushConsumer")
public class MsgConsumerListener implements RocketMQListener<NcMessage> {

    @Autowired
    MessageService messageService;

    @Override
    public void onMessage(NcMessage message) {
        log.info(message.getApplyUsername() + "申请加入企业; ");
        log.info("管理员为：" + message.getApproveUsername());
        try {
            messageService.pushSingleMessage(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
